/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package program;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author KiKiWi
 */
@Entity
@Table(name = "SONG_PLAYLIST", catalog = "", schema = "PLH24")
@NamedQueries({
    @NamedQuery(name = "SongPlaylist.findAll", query = "SELECT s FROM SongPlaylist s"),
    @NamedQuery(name = "SongPlaylist.findBySongId", query = "SELECT s FROM SongPlaylist s WHERE s.songPlaylistPK.songId = :songId"),
    @NamedQuery(name = "SongPlaylist.findByPlaylistId", query = "SELECT s FROM SongPlaylist s WHERE s.songPlaylistPK.playlistId = :playlistId")})
public class SongPlaylist implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SongPlaylistPK songPlaylistPK;

    public SongPlaylist() {
    }

    public SongPlaylist(SongPlaylistPK songPlaylistPK) {
        this.songPlaylistPK = songPlaylistPK;
    }

    public SongPlaylist(int songId, int playlistId) {
        this.songPlaylistPK = new SongPlaylistPK(songId, playlistId);
    }

    public SongPlaylistPK getSongPlaylistPK() {
        return songPlaylistPK;
    }

    public void setSongPlaylistPK(SongPlaylistPK songPlaylistPK) {
        this.songPlaylistPK = songPlaylistPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (songPlaylistPK != null ? songPlaylistPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SongPlaylist)) {
            return false;
        }
        SongPlaylist other = (SongPlaylist) object;
        if ((this.songPlaylistPK == null && other.songPlaylistPK != null) || (this.songPlaylistPK != null && !this.songPlaylistPK.equals(other.songPlaylistPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "program.SongPlaylist[ songPlaylistPK=" + songPlaylistPK + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
